. ./path.sh || exit 1;
cd ..
export CUDA_VISIBLE_DEVICES="0,1,2,3,4,5,6,7"
decode_modes="ctc_greedy_search ctc_prefix_beam_search attention attention_rescoring"

stage=5
stop_stage=5
dir=
test_sets=
train_config=
decode_checkpoint=
decode_checkpoint_name=
gpu_id=
test_data_dir="/home/work_nfs8/xlgeng/data/scp_test"
. tools/parse_options.sh || exit 1;
test_sets=$(echo "$test_sets" | sed 's/--/ /g')
echo "开始打印主要变量，这些变量有命令行传入"
echo "dir=$dir"
echo "train_config=$train_config"
echo "decode_checkpoint=$decode_checkpoint"
echo "decode_checkpoint_name=$decode_checkpoint_name"
echo "gpu_id=$gpu_id"
echo "stage=$stage"
echo "stop_stage=$stop_stage"
echo "test_sets=$test_sets"
for test_set in $test_sets; do
{
    echo "prepare test this dataset: $test_set"
}
done
wait
set -e
set -u
set -o pipefail
decoding_chunk_size=
ctc_weight=0.5
reverse_weight=0.0
blank_penalty=0.0
length_penalty=0.0
decode_batch=16
if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
  echo "Test model"
  for testset in ${test_sets}; do
  {
    result_dir=$dir/test_${decode_checkpoint_name}/${testset}
    mkdir -p "${result_dir}"
    device_id=$gpu_id
    echo "Testing ${testset} on GPU ${device_id}"
    python wenet/bin/recognize.py --gpu "${device_id}" \
      --modes "$decode_modes" \
      --config "$dir"/train.yaml \
      --data_type "shard" \
      --test_data $test_data_dir/"$testset"/data.list \
      --checkpoint "$decode_checkpoint" \
      --beam_size 10 \
      --batch_size ${decode_batch} \
      --blank_penalty ${blank_penalty} \
      --length_penalty ${length_penalty} \
      --ctc_weight $ctc_weight \
      --reverse_weight $reverse_weight \
      --result_dir "$result_dir" \
      ${decoding_chunk_size:+--decoding_chunk_size $decoding_chunk_size}
    for mode in ${decode_modes}; do
      python tools/compute-wer.py --char=1 --v=1 \
        $test_data_dir/"$testset"/text "$result_dir"/"$mode"/text > "$result_dir"/$mode/wer
    done
  }
  done
  wait
fi